local dataset = "$dataset" 
local sampletext = "$samplenametext"
local samplenamefile = "$samplenamefile"
local subsample = "$subsample"
local bspec = "$bspec"
local fe = "$fe"

clear

use "$results_fold/`dataset'"

keep if bs==0

keep diff_tfpr_b`bspec'_`fe' dif_d_bar_b`bspec'_`fe' dif_a_bar_b`bspec'_`fe' dif_cov_stay_b`bspec'_`fe' dif_var_adj_b`bspec'_`fe' adding_term_b`bspec'_`fe' drop_term_b`bspec'_`fe'

generate alt_diff_tfpr_b`bspec'_`fe' =  dif_d_bar_b`bspec'_`fe' + dif_a_bar_b`bspec'_`fe' + dif_cov_stay_b`bspec'_`fe' + dif_var_adj_b`bspec'_`fe' + adding_term_b`bspec'_`fe' + drop_term_b`bspec'_`fe'

generate tester = diff_tfpr_b`bspec'_`fe' - alt_diff_tfpr_b`bspec'_`fe' 

sum tester

generate meanE = ((dif_d_bar_b`bspec'_`fe' + dif_a_bar_b`bspec'_`fe')/diff_tfpr_b`bspec'_`fe')*100

generate MP = ((dif_cov_stay_b`bspec'_`fe' + dif_var_adj_b`bspec'_`fe' + adding_term_b`bspec'_`fe' + drop_term_b`bspec'_`fe')/diff_tfpr_b`bspec'_`fe')*100

generate incumbent = ((dif_d_bar_b`bspec'_`fe' + dif_a_bar_b`bspec'_`fe' + dif_cov_stay_b`bspec'_`fe')/diff_tfpr_b`bspec'_`fe')*100

generate extensive = (( dif_var_adj_b`bspec'_`fe' + adding_term_b`bspec'_`fe' + drop_term_b`bspec'_`fe')/diff_tfpr_b`bspec'_`fe')*100

sum meanE MP incumbent extensive 

keep meanE incumbent extensive MP

foreach variable in meanE incumbent extensive MP {
	replace `variable' = round(`variable', 0.01)
}

graph bar meanE incumbent extensive MP, ascategory scheme(s3color) yvaroptions(relabel(1 "Mean Incumbent" 2 "Incumbent All" 3 "Extensive Margin"  4 "Multi-Product"))  blabel(total) ytitle("Percent Full TFPR Effect (%)") ///
title("`sampletext'") subtitle("`subsample'")

graph export "$figures/`samplenamefile'_`bspec'_`fe'_2O1I.png", as(png) replace width(1800) height(1000)
